package com.sumainfor.wx.system.epc.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.wx.system.epc.service.MaintainCommitService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author Eddy·Chen
 * @Email 835033913@qq.com
 * @Create 2019-06-12 14:02
 * 维修评价系列
 */
@RestController
@RequestMapping("/maintain/commit")
public class MaintainCommitController {

    @Autowired
    private MaintainCommitService service;


    /**
     * 查询评价列表
     *
     * @param page
     * @param params
     * @return
     */
    @RequestMapping("/queryCommitList")
    public JsonResult queryCommitList(Page page, @RequestParam Map<String, Object> params) {
        return service.queryCommitList(page, params);
    }


    /**
     * 查询订单信息 根据维修工单编号查询
     *
     * @param repId
     * @return
     */
    @RequestMapping("/selectOrderInfo")
    public JsonResult selectOrderInfo(String repId) {
        if (StringUtils.isBlank(repId)) {
            return JsonResult.errorForEmpty();
        }
        return service.selectOrderInfo(repId);
    }


    /**
     * 获取房源信息
     *
     * @param repId
     * @return
     */
    @RequestMapping("/getHousingInfo")
    public JsonResult getHousingInfo(String repId) {
        if (StringUtils.isBlank(repId)) {
            return JsonResult.errorForEmpty();
        }
        return service.getHousingInfo(repId);
    }

    /**
     * 查询账单支付信息
     *
     * @param repId
     * @return
     */
    @RequestMapping("/getOrderPay")
    public JsonResult getOrderPay(String repId) {
        if (StringUtils.isBlank(repId)) {
            return JsonResult.errorForEmpty();
        }
        return service.getOrderPay(repId);
    }


    /**
     * 获取维修信息确认提交详情
     *
     * @param repId
     * @return
     */
    @RequestMapping("/getDetailConfirm")
    public JsonResult getDetailConfirm(String repId) {
        if (StringUtils.isBlank(repId)) {
            return JsonResult.errorForEmpty();
        }
        return JsonResult.success(service.getDetailConfirm(repId));
    }

    /**
     * 确认维修
     *
     * @param params
     * @return
     */
    @PostMapping("/confirmSubmit")
    public JsonResult confirmSubmit(@RequestBody Map<String, Object> params) {
        if (!FieldCheckUtil.isMapFieldNotNull(params, "RepId", "note", "IfRenew", "isMoney", "PayType")) {
            return JsonResult.errorForEmpty();
        }
        return service.confirmSubmit(params);
    }

}
